home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 11
/
Amoszine 11 (Disk 2 of 2).adf
/
Loads_Of_Source.lha
/
wordsearch.amos
/
wordsearch.amosSourceCode
< prev
Wrap
AMOS Source Code
|
1980-12-02
|
5KB
|
280 lines
'
' Wordsearch Maker By Dominic Ramsey
' April 91
'
' 2, The Paddocks, Haddenham, Bucks. HP17 8AG.
'
WORDSEARCH
Procedure WORDSEARCH
Screen Open 0,320,200,2,Lowres : Palette 0,$DFD
Curs Off : Hide On
Cls 0
Locate 1,1 : Centre "Wordsearch Maker By D. Ramsey"
Locate 1,6 : Centre "This program is designed to be used for"
Print : Centre "making printed wordsearch puzzles,"
Print : Centre "however, if you do not have a printer,"
Print : Centre "the puzzle can be viewed on screen."
Print : Centre "The words are from a 9000 word"
Print : Centre "dictionary stored in bank 10."
Locate 1,19 : Centre "Press mousebutton."
While Mouse Key=0 : Wend
ML:
Cls : Locate 1,10 : Centre "Please Wait, Designing Wordsearch."
SIZE=22
NW=SIZE+(SIZE/2)+4
If SIZE<15 or SIZE>30 Then Goto ML
Dim WORD$(NW+1),W$(SIZE,SIZE),X(NW+1),Y(NW+1)
For W=1 To NW
A:
R=Rnd(72000)
S=Start(10)
S=S+R
Repeat
Inc S
Until Peek(S)=13
Inc S
S$=""
While Peek(S)<>13
If Peek(S)<65 Then Goto A
S$=S$+Chr$(Peek(S))
Inc S
Wend
If Right$(S$,1)="S" and Rnd(1)=0 Then Goto A
If Len(S$)<5 or Len(S$)>(SIZE) Then Goto A
WORD$(W)=S$
Next W
'
' sort w$ to do long words first
For A=1 To NW
For B=A+1 To NW+1
If Len(WORD$(B))>Len(WORD$(A)) Then Swap WORD$(A),WORD$(B)
Next B
Next A
For A=1 To NW
Next
'
For W=1 To NW
RETRY:
D=Rnd(7)+1
TRY=1
On D Gosub UP,RT,LT,DN,UL,DR,UR
If TRY>60 Then Goto RETRY
Next W
'
'
'
DRW:
Cls
Centre "Output to screen or printer (S/P)"
Q:
Repeat : Q$=Inkey$ : Until Q$<>""
Q$=Upper$(Q$)
If Q$="S" Then Goto SCRN
If Q$="P" Then Goto PRNT
Goto Q
Stop
PRNT:
For Y=0 To SIZE
For X=0 To SIZE
If W$(X,Y)=""
W$(X,Y)=Chr$(Rnd(25)+65)
End If
Lprint W$(X,Y);" ";
Next X
Lprint
Next Y
Lprint
Sort WORD$(0)
For VV=1 To NW
If X(VV)>0 and Y(VV)>0
Lprint WORD$(VV)
End If
Next
End
'
SCRN:
Cls 0
For Y=0 To SIZE
For X=0 To SIZE
If W$(X,Y)=""
W$(X,Y)=Chr$(Rnd(25)+65)
End If
Locate X+8,Y
Print W$(X,Y);" ";
Next X
Next Y
Sort WORD$(0) : WORD$=""
For VV=1 To NW
If X(VV)>0 and Y(VV)>0
WORD$=WORD$+" "+WORD$(VV)
End If
Next
'
Screen Open 1,320,200,2,Lowres : Curs Off : Palette 0,$FDD
Print : Centre "Use Mousebutton to swap screens"
Print
Centre "==============================="
Print : Print : Print
LL=40
While Len(WORD$)>0
L$=Left$(WORD$,LL)
WORD$=Mid$(WORD$,LL+1)
R$=Right$(L$,1)
If R$<>" "
S=Instr(Flip$(L$)," ")
If S>0
R$=Right$(L$,S-1)
WORD$=R$+WORD$
L$=Left$(L$,Len(L$)-S)
End If
End If
L$=Left$(L$+Space$(LL-1),LL)
Print L$
Wend
SC=0
LP:
While Mouse Key=0 : Wend
Screen To Front SC
Wait 10
Wait Vbl
SC=SC xor 1
Goto LP
Stop
'
End
'
RT:
Inc TRY
If TRY>60 Then Return
X=Rnd(SIZE-Len(WORD$(W))-1)
Y=Rnd(SIZE-1)+1
REP=0
For A=1 To Len(WORD$(W))
If W$(X+A,Y)<>"" and(W$(X+A,Y)<>Mid$(WORD$(W),A,1)) Then REP=1
Next A
If REP=1 Then Goto RT
For A=1 To Len(WORD$(W))
W$(X+A,Y)=Mid$(WORD$(W),A,1)
Next A
X(W)=X : Y(W)=Y
Return
'
LT:
Inc TRY
If TRY>60 Then Return
X=Rnd(SIZE-1)+1
If X<Len(WORD$(W)) Then Goto LT
Y=Rnd(SIZE-1)+1
REP=0
For A=1 To Len(WORD$(W))
If W$(X-A,Y)<>"" and(W$(X-A,Y)<>Mid$(WORD$(W),A,1)) Then REP=1
Next A
If REP=1 Then Goto LT
For A=1 To Len(WORD$(W))
W$(X-A,Y)=Mid$(WORD$(W),A,1)
Next A
X(W)=X : Y(W)=Y
Return
'
DN:
Inc TRY
If TRY>60 Then Return
Y=Rnd(SIZE-Len(WORD$(W))-1)
X=Rnd(SIZE-1)+1
REP=0
For A=1 To Len(WORD$(W))
If W$(X,Y+A)<>"" and(W$(X,Y+A)<>Mid$(WORD$(W),A,1)) Then REP=1
Next A
If REP=1 Then Goto RT
For A=1 To Len(WORD$(W))
W$(X,Y+A)=Mid$(WORD$(W),A,1)
Next A
X(W)=X : Y(W)=Y
Return
'
UP:
Inc TRY
If TRY>60 Then Return
Y=Rnd(SIZE-1)+1
If Y<Len(WORD$(W)) Then Goto UP
X=Rnd(SIZE-1)+1
REP=0
For A=1 To Len(WORD$(W))
If W$(X,Y-A)<>"" and(W$(X,Y-A)<>Mid$(WORD$(W),A,1)) Then REP=1
Next A
If REP=1 Then Goto LT
For A=1 To Len(WORD$(W))
W$(X,Y-A)=Mid$(WORD$(W),A,1)
Next A
X(W)=X : Y(W)=Y
Return
'
UL:
Inc TRY
If TRY>60 Then Return
Y=Rnd(SIZE-1)+1
If Y<Len(WORD$(W)) Then Goto UL
X=Rnd(SIZE-1)+1
If X<Len(WORD$(W)) Then Goto UL
REP=0
For A=1 To Len(WORD$(W))
If W$(X-A,Y-A)<>"" and(W$(X-A,Y-A)<>Mid$(WORD$(W),A,1)) Then REP=1
Next A
If REP=1 Then Goto UL
For A=1 To Len(WORD$(W))
W$(X-A,Y-A)=Mid$(WORD$(W),A,1)
Next A
X(W)=X : Y(W)=Y
Return
'
DR:
Inc TRY
If TRY>60 Then Return
X=Rnd(SIZE-Len(WORD$(W))-1)
Y=Rnd(SIZE-Len(WORD$(W))-1)
REP=0
For A=1 To Len(WORD$(W))
If W$(X+A,Y+A)<>"" and(W$(X+A,Y+A)<>Mid$(WORD$(W),A,1)) Then REP=1
Next A
If REP=1 Then Goto DR
For A=1 To Len(WORD$(W))
W$(X+A,Y+A)=Mid$(WORD$(W),A,1)
Next A
X(W)=X : Y(W)=Y
Return
'
UR:
Inc TRY
If TRY>60 Then Return
X=Rnd(SIZE-Len(WORD$(W))-1)
Y=Rnd(SIZE-1)+1
If Y<Len(WORD$(W)) Then Goto UR
REP=0
For A=1 To Len(WORD$(W))
If W$(X+A,Y-A)<>"" and(W$(X+A,Y-A)<>Mid$(WORD$(W),A,1)) Then REP=1
Next A
If REP=1 Then Goto UR
For A=1 To Len(WORD$(W))
W$(X+A,Y-A)=Mid$(WORD$(W),A,1)
Next A
X(W)=X : Y(W)=Y
Return
'
DL:
Inc TRY
If TRY>60 Then Return
X=Rnd(SIZE-1)+1
If X<Len(WORD$(W)) Then Goto DL
Y=Rnd(SIZE-Len(WORD$(W))-1)
If Y<Len(WORD$(W)) Then Goto DL
REP=0
For A=1 To Len(WORD$(W))
If W$(X-A,Y+A)<>"" and(W$(X-A,Y+A)<>Mid$(WORD$(W),A,1)) Then REP=1
Next A
If REP=1 Then Goto DL
For A=1 To Len(WORD$(W))
W$(X-A,Y+A)=Mid$(WORD$(W),A,1)
Next A
X(W)=X : Y(W)=Y
Return
End Proc